'''
投票第一阶段，有奖励
'''
import random
def get_random(rate):
    i = random.randint(-1000000000,100000000)%100
    if i<(100*rate):
        return 1
    else:
        return 0

def init(people,rate):
    a=[]     #投票结果
    for i in range(people):
        a.append(get_random(rate[i]))    #根据比例生成随机数
    return a


def vote(Rate, people, round, growth):
    rate = [Rate]*people    #初始每个人投票率
    a=init(people,rate)    #第一轮投票
    result = []
    result.append(a.count(1) / people)    #people中第一轮的投票率
    for i in range(1,round+1):
        for i in range(len(a)):
            if a[i]==1:   #投票并且是增加了奖励力度的机制
                rate[i] = rate[i]+growth
            else:
                rate[i] = rate[i]-growth    #投票率一直在减少
        a = init(people,rate)
        result.append(a.count(1)/people)
    return result


if __name__ == '__main__':
    rate = 0.6  #初始投票率为0.6

    people = 10000      #初始投票人数
    round = 200     #投票轮数
    growth = 0.05
    a = vote(rate, people, round, growth)
    print(a)
